const path = require('path');

const fpath = 'a/a/b/ac/index.js'
const fext = path.extname(fpath)
console.log(fext) // .js